package com.jia.leetCode;

import java.util.Arrays;

/**
 * @program: Leetcode
 * @description:
 * @author: STU756
 * @create: 2020-08-24 15:20
 */
public class Pro1561 {
    public int maxCoins(int[] piles) {
        Arrays.sort(piles);
        int ans = 0;
        for(int i = 0; piles.length - 3 * i - 2 >= 0; i++) {
            ans += piles[ piles.length - 2 - 3 * i ];
        }
        return ans;
    }
}
